package com.eims.sls_app.ui;

import com.eims.sls_app.utils.AppTools;

import bls.juejin.cn.R;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomerActivity extends MyBaseActivity implements OnClickListener {
	protected static final String TAG = "CustomerActivity";
	private TextView tv_title;
	private ImageView btn_back;
	private WebView customerView;
	public String url = "https://w1011.ttkefu.com/k/linkurl/?t=9C2IFI3";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.livescores_fragment);
		initView();
		initLincer();
		getWebview();
	}

	private void initView() {
		tv_title = (TextView) findViewById(R.id.tv_title);
		tv_title.setText("在线客服");
		btn_back = (ImageView) findViewById(R.id.btn_back);
		btn_back.setVisibility(View.VISIBLE);
		customerView = (WebView) findViewById(R.id.live_scores_webview);
	}

	private void initLincer() {
		btn_back.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_back:
			finish();
			break;
		}
	}

	private void getWebview() {
		WebSettings webSettings = customerView.getSettings();

		webSettings.setJavaScriptEnabled(true);
		webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
		webSettings.setSupportMultipleWindows(true);
		// webSettings.setDisplayZoomControls(false);
		webSettings.setBuiltInZoomControls(false);
		webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
		webSettings.setDomStorageEnabled(true);

		customerView.setWebChromeClient(new WebChromeClient());

		customerView.setHorizontalScrollBarEnabled(false);
		customerView.setVerticalScrollBarEnabled(false);
		customerView.loadUrl(url);
		customerView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				Log.i(TAG, "-------" + url);
				//final PayTask payTask = new PayTask(H5PayActivity.this);
				
				
				//H5PayActivity
				//https://mobilecodec.alipay.com/client_download.htm?qrcode=bax07584n2vgf4qxzoqt6047

				view.loadUrl(url);
				return super.shouldOverrideUrlLoading(view, url);
			}

			@Override
			public void onReceivedError(WebView view, int errorCode,
					String description, String failingUrl) {

				super.onReceivedError(view, errorCode, description, failingUrl);
			}
		});
	}

}
